<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List Candidate</title>
<link rel="stylesheet" type="text/css" href="css/FinalProjectCSS.css"/>
<script type="text/javascript" src="table.js"></script>
<script type="text/javascript">
	function flyToPage(task,val) {	
		if(task=='update'||task=='detail'){
			document.forms[0].elements['cModel.userId'].value=val;
		}else if(task=='exportExcel'){
			document.forms[0].batchId.value = document.forms[0].elements['cModel.batchId'].value;
		}else if(task=='sendEmail'){
			document.forms[0].elements['cModel.to'].value=val;
		}
		document.forms[0].task.value = task;
		document.forms[0].submit();
	}

	function searchByParam(selectedParam) {
		document.forms[0].elements['param_jobcode'].value = document.getElementById('paramJobCode').value;
		document.forms[0].elements['param_regno'].value = document.getElementById('paramRegNo').value;
		document.forms[0].elements['param_fullname'].value = document.getElementById('paramFullName').value;
		document.forms[0].elements['param_techtestplace'].value = document.getElementById('paramTechTestPlace').value;
		document.forms[0].elements['param_techtestdate'].value = document.getElementById('paramTechTestDate').value;
		document.forms[0].elements['param_email'].value = document.getElementById('paramEmail').value;
		document.forms[0].elements['selectedParam'].value = selectedParam;
		document.forms[0].task.value = "listCandidate";
		document.forms[0].submit();
	}
	
	function setDisplay() {
		if(document.forms[0].elements['batchId'].value==""||document.forms[0].elements['batchId'].value==0){
			document.getElementById('exportMenu').style.display = 'none';
		}
		document.getElementById('paramJobCode').value = document.forms[0].elements['param_jobcode'].value;
		document.getElementById('paramRegNo').value = document.forms[0].elements['param_regno'].value; 
		document.getElementById('paramFullName').value = document.forms[0].elements['param_fullname'].value;
		document.getElementById('paramTechTestPlace').value = document.forms[0].elements['param_techtestplace'].value;
		document.getElementById('paramTechTestDate').value = document.forms[0].elements['param_techtestdate'].value;
		document.getElementById('paramEmail').value = document.forms[0].elements['param_email'].value;
		var selectedParam = document.forms[0].elements['selectedParam'].value;
		if(selectedParam==null) selectedParam = 'paramJobCode';
		else if(selectedParam=='') selectedParam = 'paramJobCode';
		document.getElementById(selectedParam).focus();
	}
</script>
	<%if(session.getAttribute("result") != null)
	{
		String message = session.getAttribute("result").toString();
		%>
			<script type="text/javascript">
				window.alert('<%=message%>');
			</script>
		<%
		session.removeAttribute("result");
	}%> 
</head>
<body  onkeydown="javascript:disableF5(event, '');" onload="javascript:setDisplay();">
	<center>
			<table width="100%" class="bodyTable boxShadow">
		
			<!-- HEADER -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>

			<!-- CONTAINER -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td class="headerBox blueBackground">User Management > Manage Candidate</td>
			</tr>
			<tr>
				<td align="center" class="contentStyle formListStyle"><br><br>
					<html:form action="/Candidate" method="post">
						<html:hidden property="task" name="candidateForm" />
						<html:hidden property="emailTo" name="candidateForm" />
						<html:hidden property="batchId" name="candidateForm" />
						<html:hidden property="cModel.regisNo" name="candidateForm" />
						<html:hidden property="cModel.userId" name="candidateForm" />
						<html:hidden property="cModel.to" name="candidateForm" />
						<html:hidden property="param_jobcode" name="candidateForm"/>
						<html:hidden property="param_regno" name="candidateForm"/>
						<html:hidden property="param_fullname" name="candidateForm"/>
						<html:hidden property="param_techtestplace" name="candidateForm"/>
						<html:hidden property="param_techtestdate" name="candidateForm"/>
						<html:hidden property="param_email" name="candidateForm"/>
						<html:hidden property="selectedParam" name="candidateForm"/>

						<table border="0" align="center" width="95%" class="boxShadow  example table-autosort table-autofilter table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount" id="t1">
							<thead>
									<tr align="center" class="headerBox formHeaderBackground">
										<th class="formListStyle filterable table-sortable:default">Job Code</th>
										<th class="formListStyle filterable table-sortable:default">Reg. No</th>
										<th class="formListStyle filterable table-sortable:default">Full Name</th>
										<th class="formListStyle filterable table-sortable:default">Technical Test Place</th>
										<th class="formListStyle filterable table-sortable:default">Technical Test Date</th>
										<th class="formListStyle filterable table-sortable:default">Email</th>
										<th class="formListStyle table-filterable table-sortable:default" rowspan="2">Last Status</th>
										<th class="formListStyle" rowspan="2">Action</th>
									</tr>
									<tr align="center" class="headerBox formHeaderBackground">
										<th style="padding:5px 7px;">
											<input type="text" id="paramJobCode" size="8" onchange="javascript:searchByParam('paramJobCode');" />
										</th>
										<th style="padding:5px 7px;">
											<input  type="text" id="paramRegNo" size="8" onchange="javascript:searchByParam('paramRegNo');"/>
										</th>
										<th style="padding:5px 7px;">
											<input  type="text" id="paramFullName" size="8" onchange="javascript:searchByParam('paramFullName');"/>
										</th>
										<th style="padding:5px 7px;">
											<input  type="text" id="paramTechTestPlace" size="8" onchange="javascript:searchByParam('paramTechTestPlace');"/>
										</th>
										<th style="padding:5px 7px;">
											<input  type="text" id="paramTechTestDate" size="8" onchange="javascript:searchByParam('paramTechTestDate');"/>
										</th>
										<th style="padding:5px 7px;">
											<input  type="text" id="paramEmail" size="8" onchange="javascript:searchByParam('paramEmail');"/>
										</th>					
									</tr>
								</thead>
								<tbody>	
									<logic:notEmpty name="candidateForm" property="listCandidate">
										<logic:iterate id="listData" name="candidateForm" property="listCandidate">
											<tr class="formListBackground">
												<td align="center" class="formListStyle"><bean:write name="listData" property="jobCd"/></td>
												<td align="center" class="formListStyle"><bean:write name="listData" property="regisNo"/></td>
												<td align="center" class="formListStyle"><bean:write name="listData" property="fullName"/></td>
												<td align="center" class="formListStyle"><bean:write name="listData" property="techTestPlace"/></td>
												<td align="center" class="formListStyle"><bean:write name="listData" property="techTestDate"/></td>
												<td align="center" class="formListStyle">
													<a href="javascript:flyToPage('sendEmail','<bean:write name="listData" property="email"/>');" title="Email <bean:write name="listData" property="fullName"/>" ><bean:write name="listData" property="email"/></a>
												</td>
												<td align="center" class="formListStyle"><bean:write name="listData" property="lastStatus"/></td>
												<td align="center" class="formListStyle">
													<logic:notEqual value="Accepted" property="lastStatus" name="listData">
														<a href="javascript:flyToPage('update','<bean:write name="listData" property="userId"/>');" title="Update <bean:write name="listData" property="fullName"/>">
															<img src="images/editButton.png"  width="15px" height="15px">
														</a>
													</logic:notEqual> &nbsp;
													<a href="javascript:flyToPage('detail','<bean:write name="listData" property="userId"/>');" title="Show <bean:write name="listData" property="fullName"/> detail">
														<img src="images/detailButton.png"  width="15px" height="15px">
													</a>
												</td>
											</tr>
										</logic:iterate>
									</logic:notEmpty>
									
									<logic:empty name="candidateForm" property="listCandidate">
										<tr>
											<td colspan="8" align="center">Data Empty</td>
										</tr>
									</logic:empty>
								</tbody>
								<tfoot>
									<tr id="exportMenu">
										<td colspan="8">
											<table>
												<tr>
													<td class="formListStyle"><b>Export Qualified Candidate</b></td>
												</tr>
												<tr>
													<td class="formListStyle">Choose Batch</td>
													<td class="formListStyle">
														<html:select property="cModel.batchId" name="candidateForm" styleClass="textMedium" style="height: 20px;">
															<logic:notEmpty name="candidateForm" property="listBatch">
																<html:optionsCollection name="candidateForm" property="listBatch" label="batch" value="batchId" />
															</logic:notEmpty>
														</html:select>
													</td>
													<td class="formListStyle">
														<a href="javascript:flyToPage('exportExcel','');"><img src="images/excel.jpg" width="17px" height="17px"></a>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr class="headerBox formHeaderBackground">
										<td align="left" class="formListStyle table-page:previous" style="cursor:pointer;">&lt; &lt; Previous</td>
										<td colspan="6" style="text-align:center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td>
										<td align="right" class="formListStyle table-page:next" style="cursor:pointer;">Next &gt; &gt;</td>
									</tr>
									<tr>
										<td colspan="8" id="insertButton" title="add new" align="center" class="greyBackground">						
											<div class="insertButtonGridStyle" onclick="javascript:flyToPage('insert','');">
												<table>
													<tr>
														<td class="formListStyle"><img src="images/addButton.png"></td>
														<td class="formListStyle"><b>Add New Candidate</b></td>
													</tr>
												</table>
											</div>									
										</td>
									</tr>
									<tr class="headerBox formHeaderBackground">
										<td colspan="8" align="center" style="padding:5px 7px;"><span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s)</td>
									</tr>
								</tfoot>
							</table>
					</html:form><br><br>
				</td>
			</tr>
			
			<!-- FOOTER -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy; OME.2013.All Rights Reserved.</td>
			</tr>
		</table>
	</center>
</body>
</html>
